<?php


namespace app\common\service\live;


use app\admin\model\live\Live;
use app\admin\model\live\LiveGoods;
use app\admin\model\live\LiveHost;

class LiveGoodsService
{
    /**
     * Author:YangXinPeng
     * 下拉获取直播间
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
     public static function getLives()
     {
         //判断直播间是否有直播资格
         $data = Live::where('live_can_days',">",time())->field('id,live_no')->select();
         $data && $data = $data->toArray();
         return ['code' => 1, 'msg' => null, 'data' => $data];
     }

    /**
     * Author:YangXinPeng
     * 后台展示
     * @param $page
     * @param $limit
     * @param $where
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
     public static function liveGoodInfo($page,$limit,$where)
     {
         $model = new LiveGoods();
         $count = $model->where($where)->count();
         $list = $model->where($where)
             ->with('liveGoods')
             ->page($page, $limit)
             ->order('create_time','desc')
             ->select();
         if ($list){
             $list = $list->toArray();
         }else{
             $list = [];
         }

         $data = [
             'code'  => 0,
             'msg'   => '',
             'count' => $count,
             'data'  => $list,
         ];

         return $data;
     }


}